{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pyccl as ccl\n",
    "import numpy as np"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# This is run with the version of CCL from:\n",
    "# master, commit: 1f08a44733cafee5492d3d1914ecaf4ca7f09640\n",
    "# but with accuracy parameters in src/ccl_core.c changed as:\n",
    "# A_SPLINE_NA_PK 40 (normal val) -> 100\n",
    "# A_SPLINE_NLOG_PK 11 (normal val) -> 50"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Load the original high-prec benchmarks to get the same k values:\n",
    "old_benchmark = np.load(\"../examples/pk_spline_bm.npz\")\n",
    "k = old_benchmark['k']\n",
    "z0 = old_benchmark['z0']\n",
    "z1 = old_benchmark['z1']\n",
    "z2 = old_benchmark['z2']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Get the new high-prec benchmarks\n",
    "\n",
    "cosmo = ccl.Cosmology(Omega_c=0.25, Omega_b=0.05, h=0.7, A_s=2.1e-9, n_s=0.96)\n",
    "\n",
    "pk_ln_0_bm=ccl.linear_matter_power(cosmo,k,1./(1.+z0))\n",
    "pk_nl_0_bm=ccl.nonlin_matter_power(cosmo,k,1./(1+z0))\n",
    "pk_ln_1_bm=ccl.linear_matter_power(cosmo,k,1./(1+z1))\n",
    "pk_nl_1_bm=ccl.nonlin_matter_power(cosmo,k,1./(1+z1))\n",
    "pk_ln_2_bm=ccl.linear_matter_power(cosmo,k,1./(1+z2))\n",
    "# We don't run the nonlinear case at z2=20 because the max z for \n",
    "# our halofit implementation is z=10."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Save these to a new file\n",
    "args=np.asarray([pk_ln_0_bm, pk_nl_0_bm, pk_ln_1_bm, pk_nl_1_bm, pk_ln_2_bm, \n",
    "          k, z0, z1, z2])\n",
    "kwds = np.asarray(['pk_ln_0', 'pk_nl_0', 'pk_ln_1', 'pk_nl_1', 'pk_ln_2', 'k', 'z0'\n",
    "         'z1', 'z2'])\n",
    "np.savez('../examples/pk_spline_bm_v2.npz', pk_ln_0=pk_ln_0_bm, pk_nl_0=pk_nl_0_bm,\n",
    "        pk_ln_1=pk_ln_1_bm, pk_nl_1=pk_nl_1_bm, pk_ln_2=pk_ln_2_bm,\n",
    "        k=k, z0=z0, z1=z1, z2=z2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "cclenv",
   "language": "python",
   "name": "cclenv"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.5.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
